/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package intopo.evogame.partnerselection.chromosome;

import intopo.evogame.partnerselection.config.ConstructStrategyException;
import intopo.evogame.partnerselection.config.TagException;
import intopo.game.Strategy;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.Map;
import java.util.Scanner;

/**
 * A chromosome factory.  Implementors of this interface provide a method to create a chromosome from data available in a scanner.
 * @author <a href="mailto:mariano.pedro@gmail.com">Pedro Lopes da Silva Mariano</a>
 *
 * @version 1.0 28 de Outubro de 2011
 */
public interface ChromosomeFactory<
		S extends Strategy<S>,
		C extends Chromosome<S>>
{
	/**
	 * Create a chromosome from the data available in the given scanner.  The associative map is used to construct a strategy for the chromosome.  The chromosome may have default genes as specified in constructor {@code Chromosome(S)}.
	 * <p> Implementor should use field {@code Chromosome.Parameters#defaultGenes}
	 * @see intopo.evogame.partnerselection.chromosome#Chromosome(java.util.Scanner,java.util.Map)
	 * @see intopo.evogame.partnerselection.chromosome.Chromosome.Parameters#defaultGenes Indicates if the returned chromosome has default genes or not.
	 * @param scanner  The scanner from where data is retrivied.
	 * @param map  The associative map that contains the strategy  constructors
	 * @return A chromosome constructed using the data in the scanner
	 * @throws intopo.evogame.partnerselection.TagException If the scanner
	 * @throws java.lang.InstantiationException
	 * @throws java.lang.IllegalAccessException
	 * @throws java.lang.IllegalArgumentException
	 * @throws java.lang.reflect.InvocationTargetException
	 * @throws java.io.IOException
	 */
	C create (Scanner scanner, Map<String, Constructor<? extends S>> map)
		throws
			TagException,
			ConstructStrategyException,
			IOException;
}
